<!DOCTYPE html>
<html xmlns:javascrip="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
</head>
<style>
    /*媒体查询 小于750 的样式*/
    @media screen and (max-width: 999px) {
        .mid{
            width: 100%;
            text-align: center;
            margin-top: 10px;
        }
    }
</style>
<body>

<div class="layui-card">
    <div  class="layui-form layui-card-header layuiadmin-card-header-auto">


        <form class="layui-form" action="">
            <input type="hidden" id="usercode">
            <div class="layui-inline" >
                <label class="layui-form-label">操作时间</label>
                <div class="layui-input-inline">
                    <input type="text"  id="create_time_start"  autocomplete="off" class="layui-input">
                </div>
                <span>--</span>
                <div class="layui-input-inline">
                    <input type="text" id="create_time_end"  autocomplete="off" class="layui-input">
                </div>
            </div>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </form>
    </div>

    <div class="layui-card-body">
        <div class="layui-inline mid">
            <button class="layui-btn layuiadmin-btn-order" id="search" lay-submit="" lay-filter="LAY-app-order-search">
                <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
            </button>
        </div>

        <table id="demo"  lay-filter="xx">
        </table>
    </div>
</div>
    <!--<script type="text/html" id="barDemo">-->
        <!--<a class="layui-btn  layui-btn-xs " lay-event="print">打印预览</a>-->
        <!--<a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">详情</a>-->
    <!--</script>-->


<script src="/js/include.js" type="text/javascript" charset="utf-8"></script>
<script type="text/jscript" src="/js/print.js"></script>
<!-- 注意：如果你直接复制所有代码到本地，上述js路径需要改成你本地的 -->
<script>
    var resource_name="operation_log";
    var QueryParam= new Object();


        //QueryParam.term={usercode:$('#usercode').val()};
        //layui 表格
        layui.use('table', function(){
            //表格数据装载
            var table = layui.table;
            table.render({
                id: 'idTest',
                url:'/layui/table/list/',
                method:'post',
                where: {resource_name:resource_name, querydata: JSON.stringify(QueryParam)},
                page:true,
                limits:[10,20],
                limit:10,
                elem: '#demo', //指定原始表格元素选择器（推荐id选择器）
                height: 515 ,//容器高度
                cols: [[
                    {field: 'username', title: '员工姓名'},
                    {field: 'action', title: '动作'},
                    {field: 'before_balance', title: '操作前个账余额'},
                    {field: 'after_balance', title: '操作后个账余额'},
                    {field: 'operator_code', title: '操作人工号'},
                    {field: 'operator', title: '操作人'},
                    {field: 'ip', title: 'ip地址'}
                    ]], //设置表头

                response:{
                    statusName: 'success', //数据状态的字段名称，默认：code
                    statusCode: true ,//成功的状态码，默认：0
                    msgName: 'message', //状态信息的字段名称，默认：msg
                    countName: 'count', //数据总数的字段名称，默认：count
                    dataName: 'data' //数据列表的字段名称，默认：data
                }
                //,…… //更多参数参考右侧目录：基本参数选项
            });
            //监听工具条
            table.on('tool(xx)', function tata(obj){

                var data = obj.data,layEvent = obj.event;
                if(layEvent === 'detail'){
                    //save(data.id);
                    var index = layer.open({
                        type: 2,
                        content: '/html/reimbursement_info/reimbursement_from.html?id='+data.id,
                        area: ['500px', '1000px'],
                        maxmin: false
                    });
                    layer.full(index);
                } else if(layEvent === 'print'){
                    showModelDialog('/html/reimbursement_info/reimbursement_preview.html?id='+data.id,210,297)
                }

            });
        });



    //时间控件
    layui.use('laydate',function () {
        var laydate=layui.laydate;
        //执行一个laydate实例
        laydate.render({//指定元素
            elem: '#create_time_start',
            type: 'datetime'/*,
             format:'yyyy-MM-dd HH:mm:ss'*/
        });
        //执行一个laydate实例
        laydate.render({//指定元素
            elem: '#create_time_end',
            type: 'datetime'/*,
             format:'yyyy-MM-dd HH:mm:ss'*/
        });
    })

    function parseJson(param) {
        var obj = {};
        var keyvalue = [];
        var key = "", value = "";
        var paraString = param.split("&");
        for (var i in paraString) {
            keyvalue = paraString[i].split("=");
            key = keyvalue[0];
            value = keyvalue[1];
            obj[key] = value;
        }
        return obj;
    }
    //查询
    $("#search").click(function () {
        query();
    })


    //查询共用方法
    function query () {
        var table = layui.table;
        var QueryParam= new Object();
        //2个日期都没选
        var start=$("#create_time_start").val();
        var end=$("#create_time_end").val();
        if(start==""&&end==""){
            QueryParam.range={}
        }

        //2个日期都选
        else if(!start==""&&!end==""){
            QueryParam.range={
                create_time:start+"->"+end
            }
        }
        //只选开始时间
        else if(!start==""){
            QueryParam.range={create_time:{gte:start}}
        }
        //只选结束时间
        else if(!end==""){
            QueryParam.range={create_time:{lte:end}}
        }
        table.reload('idTest', {
            where: {resource_name:resource_name, querydata: JSON.stringify(QueryParam)}
        });
    }
</script>
</body>
</html>